public class Test {

    private String name = "zy";
    private String password = "123456";


    public void login(String name, String password) {

        if (!this.name.equals(name)) {
            throw new UserPasswordException("用户名错误！");
        }
        if (!this.password.equals(password)) {
            throw new UserPasswordException("密码错误！");
        }
        System.out.println("登录成功！");
    }


    public static void main(String[] args) {
        Test test = new Test();
        try {
            test.login("zy","1234564");
        }catch (UserNameException userNameException) {
            userNameException.printStackTrace();
        }catch (UserPasswordException userPasswordException){
            userPasswordException.printStackTrace();
        }finally {

        }
    }

    public static void func(int[] a) {
        if (a == null) {
            throw new NullPointerException();
        }
    }

    public static void main2(String[] args) {
        try {
            func(null);
        }catch (NullPointerException e) {
            e.printStackTrace();
            System.out.println("捕获了NullPointerException");
        }
        System.out.println("正常逻辑");
    }

    public static void main1(String[] args) {
        /*System.out.println(10/0);
        */
        /*int[] array = null;
        System.out.println(array.length);*/

        int[] array = {1,2,3};
        System.out.println(array[10]);
    }

}
